﻿using Anke.SHManage.MSSQLDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports 
{
    public partial class LS_YCJSModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();

        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
            BindReportDataSource();
        }

        protected void BindReportDataSource()
        {

            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);        
            string txtCenter = Convert.ToString(this.Center.Text);
            string stationID = Convert.ToString(this.Station.Text);
            string doctor = Convert.ToString(this.txtDoctor.Text);
            string nurse = Convert.ToString(this.txtNurse.Text);
            string driver = Convert.ToString(this.txtDriver.Text);
            string stretcher = Convert.ToString(this.txtStretcher.Text);
            string emptyType = Convert.ToString(this.HiddenForEmptyType.Value);
            //string time = Convert.ToString(this.HiddenForTime.Value);
            //string reason = Convert.ToString(this.HiddenForReason.Value);   

            string start1 = beginTime.ToString();
            string end1 = endTime.ToString();

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_YCJS.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });
            LSDAL dal = new LSDAL();
            DataTable dt = dal.Get_LS_YCJS(beginTime, endTime, txtCenter, stationID, doctor, nurse, driver, stretcher, emptyType);
                 
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForLS_YCJS", dt));
            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}